package com.example.statemachine.machine.config;

import com.example.statemachine.machine.base.FsmMachineService;
import com.example.statemachine.machine.base.FsmStateService;
import com.example.statemachine.machine.state.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author jianwei.wang
 * @version v1.0
 * @date 2019/5/9 9:55
 **/
@Configuration
public class FsmStateMachine4Credential {

    @Resource
    private FsmStateService credentialstateserviceimpl;

    public TempStorageStateService tempStorageStateService() {
        return new TempStorageStateService(credentialstateserviceimpl);
    }

    public IsReviewStateService isReviewStateService() {
        return new IsReviewStateService(credentialstateserviceimpl);
    }

    public ReviewedStateService reviewedStateService() {
        return new ReviewedStateService(credentialstateserviceimpl);
    }

    public AntiReviewStateService antiReviewStateService() {
        return new AntiReviewStateService(credentialstateserviceimpl);
    }

    public CancelStateService cancelStateService() {
        return new CancelStateService();
    }

    @Bean(name = "fsmSMServiceForCredential")
    public FsmMachineService buildService() {
        return new FsmMachineService(tempStorageStateService(),
                isReviewStateService(),
                reviewedStateService(),
                antiReviewStateService(),
                cancelStateService());
    }
}
